/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.saving;

import java.math.BigDecimal;
import java.util.List;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import src.domain.saving.Saving;
import src.services.saving.SavingModel;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class RptSimpananPihak3DataSource implements JRDataSource{
    private int index = -1; 
    private List<Saving> savings;
    private SavingModel helper;

    public RptSimpananPihak3DataSource() {
        helper = new SavingModel();    
        savings = helper.findAll(null);
    }
    
    
    
    @Override
    public boolean next() throws JRException {
        index++;
        //return (index < data.length);
        return (index < savings.size());
    }

    @Override
    public Object getFieldValue(JRField jrf) throws JRException {
         Object value = null;
         String fieldName = jrf.getName();
         /*
          * 
          * <field name="sum_jml_awal" class="java.math.BigDecimal"/>
	<field name="sum_nom_awal" class="java.math.BigDecimal"/>
	<field name="sum_jml_debet" class="java.math.BigDecimal"/>
	<field name="sum_nom_debet" class="java.math.BigDecimal"/>
	<field name="sum_jml_kredit" class="java.math.BigDecimal"/>
	<field name="sum_nom_kredit" class="java.math.BigDecimal"/>
	<field name="sum_jml_akhir" class="java.math.BigDecimal"/>
	<field name="sum_nom_akhir" class="java.math.BigDecimal"/>
	<field name="uraian" class="java.lang.String"/>
	<field name="jum_awal" class="java.math.BigDecimal"/>
	<field name="nom_awal" class="java.math.BigDecimal"/>
	<field name="jml_debet" class="java.math.BigDecimal"/>
	<field name="nom_debet" class="java.math.BigDecimal"/>
	<field name="jum_kredit" class="java.math.BigDecimal"/>
	<field name="nom_kredit" class="java.math.BigDecimal"/>
	<field name="jum_akhir" class="java.math.BigDecimal"/>
	<field name="nom_akhir" class="java.math.BigDecimal"/>
          */
         switch (fieldName) {
             case "uraian" : value = "<urian>";break;             
             case "sum_jml_awal" : value = new BigDecimal(0.00);break;
             case "sum_nom_awal" : value = new BigDecimal(0.00);break;
             case "sum_jml_debet" : value = new BigDecimal(0.00);break;
             case "sum_nom_debet" : value = new BigDecimal(0.00);break;
             case "sum_jml_kredit" : value = new BigDecimal(0.00);break;
             case "sum_nom_kredit" : value = new BigDecimal(0.00);break;
             case "sum_jml_akhir" : value = new BigDecimal(0.00);break;
             case "sum_nom_akhir" : value = new BigDecimal(0.00);break;
             case "jml_awal" : value = new BigDecimal(0.00);break;
             case "nom_awal" : value = new BigDecimal(0.00);break;
             case "jml_debet" : value = new BigDecimal(0.00);break;
             case "nom_debet" : value = new BigDecimal(0.00);break;
             case "jml_kredit" : value = new BigDecimal(0.00);break;
             case "nom_kredit" : value = new BigDecimal(0.00);break;
             case "jml_akhir" : value = new BigDecimal(0.00);break;
             case "nom_akhir" : value = new BigDecimal(0.00);break;
         }
         return value;
    }
    
}
